//
//  YZOptionBtn.m
//  VET
//
//  Created by 刘文靖 on 2018/7/15.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZOptionBtn.h"
@interface YZOptionBtn()

@property (nonatomic, strong) UIImageView *optioniV;
@property (nonatomic, strong) UILabel *descLabel;

@end
@implementation YZOptionBtn

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setupUI];
    }
    
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    
    self = [super initWithCoder:aDecoder];
    if (self) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    self.backgroundColor = kColorWithHex(0xffffff);
    self.optioniV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox_off"]];
    [self addSubview:self.optioniV];
    [self.optioniV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.centerY.offset(0);
    }];
    
    self.descLabel = [[UILabel alloc] init];
    self.descLabel.textColor = kColorWithHex(0x393939);
    self.descLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
    [self addSubview:self.descLabel];
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.optioniV.mas_right).offset(14);
        make.centerY.offset(0);
    }];
}

- (void)setDescStr:(NSString *)descStr{
    _descStr = descStr;
    self.descLabel.text = descStr;
}

- (void)setSelected:(BOOL)selected{
    [super setSelected:selected];
    [self.optioniV setImage:[UIImage imageNamed:selected?@"checkbox_on":@"checkbox_off"]];
    
}
@end
